package scalapackage.scalamatch

import scala.util.Random


/**
  * Created by Germmy on 2018/3/30.
  */
object TypeMatch {


  def main(args: Array[String]) {


//    val tup=("zhangsan",1,3.14,true) //这里不能用元组，否则取不到里面的值

//    val obj=tup(Random.nextInt(tup.le))


    //我操，scala里面的数组也可以有不同类型
    //我感觉这里的TypeMatch根本没屌用
    val arr=Array(1,1.14,"zhangsan",true,TypeMatch)


    val obj=arr(Random.nextInt(arr.length))

//    val obj=List(1,2,3) //没有这种类型

    obj match {

      case str:String => println(s"str:$str")
      case int:Int => println(s"int:$int")
      case double:Double => println(s"double:$double")
      case boolean:Boolean => println(s"boolean:$boolean")
      case student:Student => println(s"student:$student")//永远都不会匹配到这里
      case _ : Any => println(" No Match")
    }
  }
}


class Student {

}
